<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.utils.AddDocumentUtil" %>
<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.clients.TopicServiceClient" %>

<%
     String parentPath = request.getParameter("parentPath");
 
     String sPath="/";
     try {
        AddDocumentUtil addDoc = new AddDocumentUtil(config, session);
        addDoc.addDocumentBean(request, config, session); //add bean
        addDoc.addAssociations(request, config, session); //add related documents
        addDoc.applyTags(request, config, session); //add tags
        sPath = addDoc.getSourcePath(request);
 
    /*
         TopicServiceClient client = new TopicServiceClient(config, session);
         
         String dPath = request.getParameter("diaRelDoc1");
         dPath += "../../../resources/resource.jsp?path="+dPath;
         
         String type = "Related Doc"; 
         client.addAssociation(sPath,dPath,type);
 * */
    } catch (UIException e) {
            System.out.println("Could not add documentation.");
    } catch (Exception e){
            System.out.println("Exception thrown when adding a new documentation.");
    }
     
 //   String resourcePagePath = "../resources/resource.jsp?path=" + sPath;
  //  String resourcePagePath = "dia_view_ajaxprocessor.jsp?path=" + sPath;
    String resourcePagePath = "docs_ajaxprocessor.jsp?path=" + sPath;
    response.sendRedirect(resourcePagePath);
    
    %>
 
<!--
/*
 *validation of diaRelDoc1
    if (reason == "") {
        typeForm.associationPaths.value = typeForm.associationPaths.value.replace(/^\s\s*
   ds      /, '').replace(/\s\s*$/, '');
        if (typeForm.associationPaths.value == "") {
            reason = org_wso2_carbon_registry_relations_ui_jsi18n["path.cannot.contain.only.white.spaces"];
        }
    }
 *
 */ 
-->